<?php
/**
 * @package YARBB
 * @copyright Авторские права (C) 2009 www.yar-it.com. Все права защищены.
 * @license Лицензия http://www.gnu.org/licenses/gpl-2.0.htm GNU/GPL, или help/license.php
 * YARBB! - свободное программное обеспечение распространяемое по условиям лицензии GNU/GPL
 * Для получения информации о используемых расширениях и замечаний об авторском праве, смотрите файл copyright.php.
 */
/** no direct access */
defined( '_VALID_MOS' ) or die( '' );

// If the "Show text" button was clicked
if (isset($_POST['assign_award'])) {
	// Make sure something something was entered
	if (trim($_POST['award_user_id']) == '')
		mosRedirect('index2.php?option=com_forum&amp;task=awards', _Y_AWSUSADDIDD);
	$sql = ('UPDATE #__forum_users
					SET imgaward="'.$database->getEscaped($_POST['award_filename']).'" 
					WHERE id="'.intval($_POST['award_user_id']).'" LIMIT 1');
	$database->setQuery($sql);
	$database->Query($sql);

	mosRedirect( 'index2.php?option=com_forum&amp;task=awards', _Y_AWSUSADD);
}
else	// If not, we show the "Show text" form
{

	// Generate a dropdown for all the awards ...
	$awardmod_dropdown = '<select name="award_filename" tabindex="2"><option value="">'._Y_AWDELALL.'</option>';
	// figure out what files we have ...
	$awardmod_directory = dir($yarbb_path.'/img/awards/');
	while(($awardmod_temp = $awardmod_directory->read()) != false) {
		if(!is_dir($awardmod_temp) && $awardmod_temp != 'index.html') {
			$awardmod_dropdown .= '<option value="'.$awardmod_temp.'">'.str_replace('_',' ',substr($awardmod_temp,0,strrpos($awardmod_temp,'_'))).'</option>';
		}
	}
	$awardmod_directory->close();
	$awardmod_dropdown .= '</select>';
	?>
<table class="adminheading">
	<tr>
		<th class="menus"> <span><?php echo _Y_AWARDS; ?></span> </th>
	</tr>
</table>
<table class="adminform">
	<tr>
		<td class="message"><?php echo _Y_AWDESC; ?> <?php echo _Y_AWDESC2; ?> </td>
	</tr>
</table>
<form id="new" method="post" action="<?php echo $_SERVER['REQUEST_URI'] ?>">
	<table class="adminform">
		<tr>
			<th colspan="3" ><?php echo _Y_AWUSR; ?></th>
		</tr>
		<tr>
			<td width="20%"><?php echo _Y_AWIDUSR; ?></td>
			<td><input type="text" name="award_user_id" size="5" tabindex="1" />
				<span><?php echo mosToolTip(_Y_AWIDUSR2); ?></span> </td>
		</tr>
		<tr>
			<td><?php echo _Y_AWNAGR; ?> </td>
			<td><?php echo $awardmod_dropdown; ?> <span><?php echo mosToolTip(_Y_AWNAGR2); ?></span> </td>
		</tr>
		<tr>
			<td><input type="submit" name="assign_award" value="<?php echo _Y_AWUSR; ?>" tabindex="3" /></td>
		</tr>
	</table>
</form>
	<?php
}